<page-header [autoTitle]="false"></page-header>
<nz-card>
  <section class="search-section">
    <input nz-input placeholder="姓名、手机" [(ngModel)]="keyword" class="search-item"/>
    <nz-select [(ngModel)]="levelId" [nzPlaceHolder]="'渠道级别'" class="search-item" [nzAllowClear]="true" [nzShowSearch]="true">
      <nz-option
        *ngFor="let option of levelOptions"
        [nzLabel]="option.name"
        [nzValue]="option.id">
      </nz-option>
    </nz-select>
    <nz-select [(ngModel)]="districtId" [nzPlaceHolder]="'所属运营中心'" class="search-item" [nzAllowClear]="true" [nzShowSearch]="true">
      <nz-option
        *ngFor="let option of districtOption"
        [nzLabel]="option.name"
        [nzValue]="option.id">
      </nz-option>
    </nz-select>
    <button nz-button [nzType]="'primary'" nzGhost (click)="search()" class="search-item">
      <i class="anticon anticon-search"></i><span>搜索</span>
    </button>
    <button nz-button [nzType]="'primary'" (click)="editEntity({})" class="search-add-right">
      <i class="anticon anticon-plus"></i><span>添加</span>
    </button>
  </section>
  <nz-table #nzTable [nzData]="page.content"
            [nzPageSize]="page.size"
            [nzTotal]="page.totalElements"
            [nzFrontPagination]="false"
            [(nzPageIndex)]="page.number"
            (nzPageIndexChange)="changePageNo($event)"
            [nzLoading]="isLoading">
    <thead>
    <tr>
      <th nz-th><span>序号</span></th>
      <th nz-th><span>姓名</span></th>
      <th nz-th><span>手机</span></th>
      <!--<th nz-th><span>身份证号</span></th>-->
      <th nz-th><span>渠道级别</span></th>
      <th nz-th><span>运营中心</span></th>
      <th nz-th><span>上级渠道</span></th>
      <!--<th nz-th><span>进货总额(￥)</span></th>-->
      <!--<th nz-th><span>出货总额(￥)</span></th>-->
      <!--<th nz-th><span>零售总额(￥)</span></th>-->
      <th nz-th><span>普通账户余额(￥)</span></th>
      <th nz-th><span>零售账户余额(￥)</span></th>
      <th nz-th><span>加入时间</span></th>
      <th nz-th><span>是否激活</span></th>
      <th nz-th><span>操作</span></th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of nzTable.data;let i=index">
      <td>
        {{i+1}}
      </td>
      <td>{{data.name}}</td>
      <td>{{data.phone}}</td>
      <!--<td>{{data.idNumber}}</td>-->
      <td>{{data.levelId | dicsNamePipe:levelOptions:"id":"name"}}</td>
      <td>{{data.districtId|dicsNamePipe:districtOption:"id":"name"}}</td>
      <td>{{data.parentAgent?data.parentAgent.name:"无"}}</td>
      <!--<td>{{data.totalIn}}</td>-->
      <!--<td>{{data.totalOut}}</td>-->
      <!--<td>{{data.totalSell}}</td>-->
      <td>{{data.balance}}</td>
      <td>{{data.retailBalance}}</td>
      <td>{{data.createdAt}}</td>
      <td>{{data.status|yesNoPipe}}</td>
      <td>
        <a href="javascript:void (0);" routerLink="/agent/list/agent-detail" [queryParams]="{id: data.id}">查看详情</a>
        <nz-divider nzType="vertical"></nz-divider>
        <nz-dropdown>
          <a nz-dropdown>
            更多 <i class="anticon anticon-down"></i>
          </a>
          <ul nz-menu nzSelectable>
            <li nz-menu-item>
              <a href="javascript:void (0);" (click)="agentRecharge(data)">充值</a>
            </li>
            <li nz-menu-item>
              <a href="javascript:void (0);" (click)="updateLevel(data)">调整等级</a>
            </li>
            <li nz-menu-item *ngIf="data.levelId != 4">
              <a href="javascript:void (0);" (click)="upToTop(data)">晋级为市级独代</a>
            </li>
            <li nz-menu-item>
              <a href="javascript:void (0);" (click)="setPassword(data)">重置密码</a>
            </li>
            <li nz-menu-item *ngIf="data.levelId == 4 || data.levelId == 5">
              <a href="javascript:void (0);" (click)="setCityArea(data)">设置独代区域</a>
            </li>
          </ul>
        </nz-dropdown>
        <!--<nz-divider nzType="vertical"></nz-divider>
        <nz-popconfirm [nzTitle]="'确定要删除这条数据吗？'" (nzOnConfirm)="delete(data)">
          <a nz-popconfirm>删除</a>
        </nz-popconfirm>-->
      </td>
    </tr>
    </tbody>
  </nz-table>
</nz-card>
